<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function gettime(num){
            var arr = ["零","一","二","三","四","五","六","七","八","九","十"]
            if(num>=0&&num<=10){
                return arr[num]
            }else if(num>10&&num<20){
                num = num+""
                return "十"+arr[num[1]];
            }else if(num>20&&num%10!=0){
                num = num+""
                return arr[num[0]]+"十"+arr[num[1]]
            }else if(num%10==0){
                num = num+""
                return arr[num[1]]+"十"
            }else{
               return "给爷爬" 
            }
        }



        function fn(){
        var time = new Date()
        var year =getyy(time.getFullYear())
        var month = gettime(time.getMonth())
        var day = gettime(time.getDate())
        var hour = gettime(time.getHours())
        var minute = gettime(time.getMinutes())
        var second = gettime(time.getSeconds())
        var str = `现在时间是${year}年${month}月${day}日${hour}时${minute}分${second}秒`;
        document.body.innerHTML = str
    }
    fn()
    setInterval(function(){
        fn()
    },1000)

    function getyy(year){
        year = year + ""
        var str = ""
        for(var i = 0;i<year.length;i++){
            str += gettime(year[i])
        }
        return str
    }
    </script>
</body>
</html>